//
//  UIBarButtonItem+Extension.swift
//  WYWeibo
//
//  Created by wangyi on 16/7/9.
//  Copyright © 2016年 wangyi. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    //构造函数
    convenience init(title: String, target: AnyObject?, action: Selector) {
        self.init()
        let button = UIButton()
        
        //设置点击事件
        button.addTarget(target, action: action, forControlEvents: .TouchUpInside)
//        设置文字
        button.setTitle(title, forState: .Normal)
        
        //设置字体
        button.setTitleColor(UIColor.darkGrayColor(), forState: .Normal)
        button.setTitleColor(UIColor.orangeColor(), forState: .Highlighted)
        //大小
        button.titleLabel?.font = UIFont.systemFontOfSize(14)
        //适配
        button.sizeToFit()
        //设置 customView
        customView = button
    }
}
